package Test_C3p0;

import utli.Util_Class;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Test_C3p0 {
    public static void main(String[] args) {
        Connection connection = null;
        PreparedStatement statement = null;

        try {
            //原来是自己实现的，现在使用别人实现的
            connection = Util_Class.get_connection();
            //使用 ？ 占位符代替参数
            String sql = "insert into `users`(`id`,`NAME`,`PASSWORD`,`email`,`birthday`)values (?,?,?,?,?)";
            statement = connection.prepareStatement(sql);

            //手动给参数赋值
            statement.setInt(1, 6);
            statement.setString(2, "郭八");
            statement.setString(3, "1223456");
            statement.setString(4, "31233@qq.com");
            statement.setDate(5, new Date(new java.util.Date().getTime()));

            //执行
            int num= statement.executeUpdate();
            if (num>0){
                System.out.println("插入成功");
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            Util_Class.release(connection, statement, null);

        }




    }
}
